package com.example.file_management.model;

import lombok.Data;

@Data
public class ApiResponse {
    private int code;       // 状态码
    private String message; // 返回消息
    private Object data;    // 返回数据（可选）

    // 成功的响应
    public static ApiResponse success(String message) {
        return new ApiResponse(200, message, null);
    }

    public static ApiResponse success(String message, Object data) {
        return new ApiResponse(200, message, data);
    }

    // 失败的响应
    public static ApiResponse failure(String message) {
        return new ApiResponse(400, message, null);
    }

    public static ApiResponse failure(String message, Object data) {
        return new ApiResponse(400, message, data);
    }

    // 构造函数
    public ApiResponse(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}